from system_template.exploring_stores_system_template import system_template_text ,user_template_text
from langchain.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from langchain.output_parsers import PydanticOutputParser
from xiaohonghus_modle import Xiaohongshu

def xiaohongshu_jenerator(theme,api_key):
    prompt = ChatPromptTemplate.from_messages([
        ("system", system_template_text),
        ("user", user_template_text),
    ])
    llm = ChatOpenAI(model = "gpt-3.5-turbo",temperature=0,openai_api_key=api_key)
    output_parser = PydanticOutputParser(pydantic_object=Xiaohongshu)
    chain = prompt | llm | output_parser
    res = chain.invoke({"theme" : theme , "parser_instruction":output_parser.get_format_instructions()})
    return res
